package com.wbcs.system.intercept;

import java.util.List;

import com.wbcs.config.component.application.report.ReportBean;
import com.wbcs.system.ReportRequest;
import com.wbcs.util.RegexTools;
import com.wbcs.util.Tools;

public abstract class AbsPageInterceptor
{
    private String matchpageids;

    private String matchmode;

    private List<String> lstMatchPageids;

    public String getMatchpageids()
    {
        return matchpageids;
    }

    public void setMatchpageids(String matchpageids)
    {
        this.matchpageids=matchpageids;
    }

    public String getMatchmode()
    {
        return matchmode;
    }

    public void setMatchmode(String matchmode)
    {
        this.matchmode=matchmode;
    }

    public boolean isMatch(String pageid)
    {
        if(pageid==null||pageid.trim().equals("")) return false;
        if(this.matchpageids==null||this.matchpageids.trim().equals("")) return true;
        if(matchmode!=null&&matchmode.trim().equalsIgnoreCase("regex"))
        {
            return RegexTools.isMatch(pageid,this.matchpageids);
        }else
        {
            if(lstMatchPageids==null)
            {
                synchronized(this)
                {
                    if(lstMatchPageids==null) lstMatchPageids=Tools.parseStringToList(this.matchpageids,";",false);
                }
            }
            return lstMatchPageids.contains(pageid);
        }
    }

    public void doStart(ReportRequest rrequest)
    {

    }

    public void doStartSave(ReportRequest rrequest,List<ReportBean> lstSaveReportBeans)
    {

    }

    public void doEndSave(ReportRequest rrequest,List<ReportBean> lstSaveReportBeans)
    {

    }

    public void doEnd(ReportRequest rrequest)
    {

    }

    
}
